<?php
namespace AuctionCore\AuctionOrder;


/**
* 车主确认功能 测试类
* @author       爱民
*/
class OwnerConfirmTest extends \PHPUnit_Framework_TestCase
{
	private $test_owner_id = 3;
	private $confirm_info = array(
			'owner_id'=>'3' //车主编号
			,'reserve_time'=>'2015-12-02 15:15:15'//预约时间
			,'service_method'=>'1'//服务方式
			,'province'=>'11'//预约省
			,'city'=>'12'//预约市
			,'area'=>'12'//预约地区
			,'address'=>'老北京第一胡同15号'//预约地址
			,'next_trace_time'=>'2015-12-01 15:15:15'//下次跟踪时间
			,'remark'=>'车主确认备注'//备注
			,'result'=>''//确认结果  1同意 2继续跟踪 3重拍 4不卖
	);

	public function testAgree(){
		//同意买车
		$owner_confirm = new OwnerConfirm($this->test_owner_id);
		$confirm_info = $this->confirm_info;
		unset($confirm_info['next_trace_time']);		
		$owner_confirm->agree($confirm_info);		
		$detail = $owner_confirm->detail();
		$this->assertEquals(6,$detail['au_status']);	
	}

	public function testReAuction(){
		//重拍
		$owner_confirm = new OwnerConfirm($this->test_owner_id);
		$owner_confirm->re_auction('车主要求重拍');
		$m = M('owner_confirm_log');
		$log = $m->order('ocl_id desc')->limit(1)->find();
		$this->assertEquals(3,$log['result']);
	}

	public function testConTrace(){
		//继续跟踪
		$owner_confirm = new OwnerConfirm($this->test_owner_id);				
		$owner_confirm->con_trace('车主确认继续跟踪','2015-12-01 15:15:15');		
		$m = M('owner_confirm_log');
		$log = $m->order('ocl_id desc')->limit(1)->find();
		$this->assertEquals(2,$log['result']);
	}

	public function testRefuseSold(){
		//车主不卖了
		$owner_confirm = new OwnerConfirm($this->test_owner_id);				
		$owner_confirm->refuse_sold('车主确认不卖了');	

		$m = M('owner_confirm_log');
		$log = $m->order('ocl_id desc')->limit(1)->find();
		$this->assertEquals(4,$log['result']);	

		$detail = $owner_confirm->detail();		
		$this->assertEquals(12,$detail['au_status']);		
		$this->assertEquals(2,$detail['au_fail_type']);
	
		$m = M('Cars');
		$info = $m->where('car_id=\''.$detail['car_id'].'\'')->find();
		$this->assertEquals(8,$info['car_status']);
	}

	



}

?>